local joy__shenzhen = fk.CreateSkill {

  name = "joy__shenzhen",

  tags = {  },

}



joy__shenzhen:addEffect(fk.TurnStart, {
  name = "joy__shenzhen",
  anim_type = "control",
  events = {fk.TurnStart},
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(joy__shenzhen.name) and player:getMark("@joy__remedy") > 0
  end,
  on_cost = function(self, event, target, player, data)
    local _, dat = player.room:askForUseActiveSkill(player, "joy__shenzhen_active", "#joy__shenzhen-invoke", true)
    if dat then
      event:setCostData(self, dat)
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local targets = event:getCostData(self).targets
    room:removePlayerMark(player, "@joy__remedy", #targets)
    room:sortPlayersByAction(targets)
    for _, id in ipairs(targets) do
      local p = room:getPlayerById(id)
      if not p.dead then
        if event:getCostData(self).interaction == "recover" then
          if not p.dead and p:isWounded() then
            room:recover { num = 1, skillName = joy__shenzhen.name, who = p, recoverBy = player }
          end
        else
          room:loseHp(p, 1, joy__shenzhen.name)
        end
      end
    end
  end,
})

return joy__shenzhen